extends Node


func get_collision_polygon_size(collision_polygon: CollisionPolygon2D) -> Vector2:
	var points = collision_polygon.polygon
	if points.size() == 0:
		return Vector2.ZERO
	
	# 初始化最小和最大坐标
	var min_x = INF
	var min_y = INF
	var max_x = -INF
	var max_y = -INF
	
	# 遍历所有点，计算边界
	for point in points:
		min_x = min(min_x, point.x)
		min_y = min(min_y, point.y)
		max_x = max(max_x, point.x)
		max_y = max(max_y, point.y)
	
	# 计算宽度和高度
	var width = max_x - min_x
	var height = max_y - min_y
	
	return Vector2(width, height)
